package com.example.chasshelper;

import androidx.appcompat.app.AppCompatActivity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.RadioGroup;

import com.example.chasshelper.dao.ClassroomDao;
import com.example.chasshelper.dao.CourseDao;
import com.example.chasshelper.dao.MessageDao;
import com.example.chasshelper.dao.RegistrationDao;
import com.example.chasshelper.dao.SolutionDao;
import com.example.chasshelper.dao.StudentDao;
import com.example.chasshelper.dao.TeacherDao;
import com.example.chasshelper.dao.TestDao;
import com.example.chasshelper.utils.DaoUtils;

public class EditInformationActivity extends AppCompatActivity implements View.OnClickListener{
    private static final String TAG = EditInformationActivity.class.getSimpleName();
    private final Activity mContext = EditInformationActivity.this;
    //控件
    private ImageView iv_back;
    private Button btn_save;
    private EditText et_userName;
    private RadioGroup rg_sex;
    private EditText et_age;
    private EditText et_school;
    private EditText et_major;
    private EditText et_userClass;

    private RadioButton rb_current;
    //dao
    private TeacherDao teacherDao= DaoUtils.getTeacherDao();
    private StudentDao studentDao=DaoUtils.getStudentDao();
    private CourseDao courseDao=DaoUtils.getCourseDao();
    private ClassroomDao classroomDao=DaoUtils.getClassroomDao();
    private RegistrationDao registrationDao=DaoUtils.getRegistrationDao();
    private SolutionDao solutionDao = DaoUtils.getSolutionDao();
    private MessageDao messageDao = DaoUtils.getMessageDao();
    private TestDao testDao = DaoUtils.getTestDao();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_edit_information);
        initUI();
        initData();
    }
    /*
     * 界面初始化
     * */
    private void initUI() {
        //绑定控件
        iv_back = findViewById(R.id.iv_back);
        btn_save = findViewById(R.id.btn_save);
        et_userName = findViewById(R.id.et_userName);
        rg_sex = findViewById(R.id.rg_sex);
        et_age = findViewById(R.id.et_age);
        et_school = findViewById(R.id.et_school);
        et_major = findViewById(R.id.et_major);
        et_userClass = findViewById(R.id.et_userClass);
        //点击事件
        iv_back.setOnClickListener(this);
        btn_save.setOnClickListener(this);
    }

    /*
     * 数据初始化
     * */
    private void initData() {
        //dao

        //adapter
    }

    //点击事件
    @Override
    public void onClick(View view) {
        Intent intent = new Intent();
        String userName = et_userName.getText().toString();
        String sex = "未选中";
        if (rg_sex.getCheckedRadioButtonId() != -1) {
            rb_current = findViewById(rg_sex.getCheckedRadioButtonId());
            sex = rb_current.getText().toString();
        }
        String age = et_age.getText().toString();
        String school = et_school.getText().toString();
        String major = et_major.getText().toString();
        String userClass = et_userClass.getText().toString();
        //测试
        System.out.println("用户名："+userName+"，性别："+sex+"，年龄："+age+"，学校："+school+"，专业："+major+"，班级："+userClass);

        switch (view.getId()) {
            case R.id.iv_back:
                finish();
                break;
            case R.id.btn_save:
                finish();
                break;
        }
    }
}